public class Draw {
    private int height;


    public Draw(int height) {
       this.height = height;
    }
    //绘制三角形
    public void drawsanjiao() {
        for (int i = 1; i <= height; i++) {
            for (int j = 0; j < i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    // 绘制矩形
    public void drawjuxing(int width) {
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < width; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    // 绘制正方形
    public void drawzheng(int sideLength) {
        drawjuxing(sideLength);
    }

    // 绘制平行四边形
    public void drawpingxing(int baseWidth) {
        int offset = (baseWidth - height) / 2;
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < offset + i; j++) {
                System.out.print(" ");
            }
            for (int k = 0; k < baseWidth; k++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    public static void main(String[] args) {

        Draw draw = new Draw(5);


        System.out.println("绘制三角形：");
        draw.drawsanjiao();
        System.out.println();

        System.out.println("绘制矩形：");
        draw.drawjuxing(7);
        System.out.println();

        System.out.println("绘制正方形：");
        draw.drawzheng(5);
        System.out.println();

        System.out.println("绘制平行四边形：");
        draw.drawpingxing(6);
    }
}